import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/index/index'
import tools from '@/views/tools/index'
import Item from '@/views/tools/item'
// 格式化
import JSView from '@/views/tools/format/js'
import CSSView from '@/views/tools/format/css'
// 文本处理转换
import UpLowerView from '@/views/tools/text/up-lower'
import CountView from '@/views/tools/text/count'
import ReplaceView from '@/views/tools/text/replace'
import LengthView from '@/views/tools/text/length'
import ToFileView from '@/views/tools/text/tofile'
import IconFontView from '@/views/tools/text/iconfont'
// 颜色
import RGBView from '@/views/tools/color/rgb'
// 加密与解密
import MD5View from '@/views/tools/secret/md5'
import URLHexView from '@/views/tools/secret/urlhex'
import Base64View from '@/views/tools/secret/base64'
import EncodeView from '@/views/tools/secret/encode'
// 图片
import SpriteView from '@/views/tools/photo/sprite'
import FlowView from '@/views/tools/photo/flow'
import QRCodeView from '@/views/tools/photo/qrcode'
// 服务
import ProxyView from '@/views/tools/service/proxy'
// 文档
import SymbolView from '@/views/tools/appendix/symbol'
import ContrastView from '@/views/tools/appendix/contrast'
import ColoursView from '@/views/tools/appendix/colours'
import RegExpView from '@/views/tools/appendix/regexp'
import KeyCodeView from '@/views/tools/appendix/keycode'
import HTTPCodeView from '@/views/tools/appendix/http-code'
import ContentTypeView from '@/views/tools/appendix/content-type'
import ASCIIView from '@/views/tools/appendix/ascii'
import PortView from '@/views/tools/appendix/port'
import config from '@/micros/config'

Vue.use(Router)


// 判断环境是否是微应用打开
let microPath = ''
if (window.__POWERED_BY_QIANKUN__) {
  microPath = config.microPath
}

export default new Router({
  routes: [
    {
      path: microPath + '/',
      name: 'index',
      component: Index
    },
    {
      path: microPath + '/home',
      name: 'index',
      component: Index
    },
    {
      path: microPath + '/tools',
      name: 'tools',
      component: tools
    },
    {
      path: microPath + '/tools/item',
      name: 'toolsItem',
      component: Item,
      children: [
        // 格式化
        {
          path: 'json',
          name: 'json',
          component: () => import(/* webpackChunkName: "json" */ '@/views/tools/format/json')
        },
        {
          path: 'js',
          name: 'js',
          component: JSView
        },
        {
          path: 'css',
          name: 'css',
          component: CSSView
        },
        // 文本处理转换
        {
          path: 'uplower',
          name: 'uplower',
          component: UpLowerView
        },
        {
          path: 'count',
          name: 'count',
          component: CountView
        },
        {
          path: 'replace',
          name: 'replace',
          component: ReplaceView
        },
        {
          path: 'length',
          name: 'length',
          component: LengthView
        },
        {
          path: 'compare',
          name: 'compare',
          component: () => import(/* webpackChunkName: "compare" */ '@/views/tools/text/compare')
        },
        {
          path: 'tofile',
          name: 'tofile',
          component: ToFileView
        },
        {
          path: 'iconfont',
          name: 'iconfont',
          component: IconFontView
        },
        // 编译
        {
          path: 'less',
          name: 'less',
          component: () => import(/* webpackChunkName: "less" */ '@/views/tools/compile/less')
        },
        // 颜色
        {
          path: 'rgb',
          name: 'rgb',
          component: RGBView
        },
        // 加密与解密
        {
          path: 'md5',
          name: 'md5',
          component: MD5View
        },
        {
          path: 'urlhex',
          name: 'urlhex',
          component: URLHexView
        },
        {
          path: 'base64',
          name: 'base64',
          component: Base64View
        },
        {
          path: 'encode',
          name: 'encode',
          component: EncodeView
        },
        // 图片
        {
          path: 'sprite',
          name: 'sprite',
          component: SpriteView
        },
        {
          path: 'flow',
          name: 'flow',
          component: FlowView
        },
        {
          path: 'qrcode',
          name: 'qrcode',
          component: QRCodeView
        },
        // 服务
        {
          path: 'proxy',
          name: 'proxy',
          component: ProxyView
        },
        // 文档
        {
          path: 'symbol',
          name: 'symbol',
          component: SymbolView
        },
        {
          path: 'contrast',
          name: 'contrast',
          component: ContrastView
        },
        {
          path: 'colours',
          name: 'colours',
          component: ColoursView
        },
        {
          path: 'regexp',
          name: 'regexp',
          component: RegExpView
        },
        {
          path: 'keycode',
          name: 'keycode',
          component: KeyCodeView
        },
        {
          path: 'httpcode',
          name: 'httpcode',
          component: HTTPCodeView
        },
        {
          path: 'contenttype',
          name: 'contenttype',
          component: ContentTypeView
        },
        {
          path: 'ascii',
          name: 'ascii',
          component: ASCIIView
        },
        {
          path: 'port',
          name: 'port',
          component: PortView
        }
      ]
    }
  ]
})
